package dao.impl;

import java.sql.SQLException;

import org.apache.commons.dbutils.QueryRunner;

import dao.CollectionDao;
import entity.Collection;
import util.C3P0Util;

public class CollectionDaoImpl implements CollectionDao{

	@Override
	public int addCollection(Collection c) {
		QueryRunner qr = new QueryRunner(C3P0Util.getDataSource());
		String sql = "insert into collection values(null,?,?,?,?,?)";
		Object[] param = {c.getProduct_name(),c.getPrice(),c.getPic_url(),c.getUser_id(),c.getproduct_id()};
		int i = 0;
		try {
			 i = qr.update(sql, param);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return i;
	}

}
